package com.server.user.controller;

import com.server.model.all.constant.preAuthorize.MenuPreAuthorizeConstant;
import com.server.common.security.code.anntation.PreAuthorize;
import com.server.model.all.user.dto.TreeMenuDto;
import com.server.common.code.utils.AjaxResult;
import com.server.model.all.user.dto.ListMenuDto;
import com.server.user.service.MenuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 菜单
 * @author LXC
 * @date 2022/5/5 13:17
 */
@RestController
@RequestMapping(path = "/systemMenu")
@Api(value = "菜单",tags = "菜单")
public class MenuController {

    @Resource
    private MenuService menuService;

    /**
     * 菜单列表
     * @author LXC
     * @date 2022/5/6 9:26
     */
    @PostMapping("/listMenu")
    @PreAuthorize(hasPre = MenuPreAuthorizeConstant.MENU_LIST)
    @ApiOperation(value = "菜单列表",notes = MenuPreAuthorizeConstant.MENU_LIST)
    public AjaxResult listMenu(@RequestBody @Validated ListMenuDto listMenuDto){
        return AjaxResult.successData(menuService.listMenu(listMenuDto));
    }

    /**
     * 树形菜单
     * @author LXC
     * @date 2022/5/6 16:24
     */
    @PostMapping("/treeMenu")
    @PreAuthorize(hasPre = MenuPreAuthorizeConstant.MENU_TREE)
    @ApiOperation(value = "树形菜单",notes = MenuPreAuthorizeConstant.MENU_TREE)
    public AjaxResult treeMenu(@RequestBody @Validated TreeMenuDto treeMenuDto){
        return AjaxResult.successData(menuService.treeMenu(treeMenuDto));
    }

}
